package www.dianbaozu.com.extension

import www.wen.com.common.lib.data.entities.UseInfoEntity
import www.wen.com.common.lib.data.entities.VerifyCodeRegisterEntity
import www.wen.com.common.lib.helper.loading.KeyHelper
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_ACCESS_TOKEN
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_ACCID
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_ACC_TOKEN
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_AVATAR
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_BIRTHDAY
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_CITY
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_CREATE_TIME
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_EMAIL
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_EXPIRES_IN
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_FORBIDSTATUS
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_GENDER
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_ID
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_INTRO
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_MOBILE
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_NICKNAME
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_ONLINESTATUS
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_PLATFORM
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_PROVINCE
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_REFRESH_TOKEN
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_SCOPE
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_TOKEN_TYPE
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_UPDATE_TIME
import www.wen.com.common.lib.helper.loading.KeyHelper.MMKV_WX_UNIONID
import www.wen.com.common.lib.util.SpUtil

/**
 * @author WEN
 * @Description:
 * @date 2021/9/14 10:24
 */


fun SpUtil.save(verifyCodeRegisterEntity: VerifyCodeRegisterEntity){
    verifyCodeRegisterEntity.run {
        encode(MMKV_ACCESS_TOKEN,access_token)
        encode(MMKV_TOKEN_TYPE,token_type)
        encode(MMKV_REFRESH_TOKEN,refresh_token)
        encode(MMKV_EXPIRES_IN,expires_in)
        encode(MMKV_SCOPE,scope)
    }
}

fun SpUtil.save(useInfoEntity: UseInfoEntity){
    useInfoEntity.run {
        encode(MMKV_ACCID, accId)
        encode(MMKV_ACC_TOKEN, accToken)
        encode(MMKV_AVATAR, avatar)
        encode(MMKV_BIRTHDAY, birthday)
        encode(MMKV_CITY, city)
        encode(MMKV_CREATE_TIME, createTime)
        encode(MMKV_EMAIL, email)
        encode(MMKV_FORBIDSTATUS, forbidStatus)
        encode(MMKV_GENDER, gender)
        encode(MMKV_ID, id)
        encode(MMKV_INTRO, intro)
        encode(MMKV_NICKNAME, nickName)
        encode(MMKV_ONLINESTATUS, onlineStatus)
        encode(MMKV_PLATFORM, platform)
        encode(MMKV_PROVINCE, province)
        encode(MMKV_UPDATE_TIME, updateTime)
        encode(MMKV_WX_UNIONID, wxUnionId)
        encode(MMKV_MOBILE, mobile)
        encode(KeyHelper.MMKV_LOGIN_TIME, System.currentTimeMillis() / 1000)
    }
}

